{{if $member_info['loginname'] == ''}}
<script type="text/javascript">
window.location.href="/page_login";
</script>
{{/if}}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>投资者之家--留言板</title>
    <link rel="stylesheet" href="{{$static_path}}/static/common/css/reset.css">
    <link rel="stylesheet" href="{{$static_path}}/static/common/css/swiper_2.7.css">
    <link rel="stylesheet" href="{{$static_path}}/static/common/css/header.css">
    <link rel="stylesheet" href="{{$static_path}}/static/common/css/footer.css">
    <link rel="stylesheet" href="{{$static_path}}/static/css/investors/iconfont/iconfont.css">
    <link rel="stylesheet" href="{{$static_path}}/static/css/investors/list_investors_post.css">
    <link rel="stylesheet" href="{{$static_path}}/static/common/css/common.css">
    <script src="{{$static_path}}/static/common/js/jquery-1.11.3.js"></script>
</head>

<body>
    <!-- 头部部分 -->
    {{include file="header.tpl"}}
    <!-- 内容区域 -->
    <div class="dh-main">
        <div class="zj-banner"></div>
        <div class="main-content">
            <div class="main-left">
                <div class="dh-top1">
                    <p class="h-top">投资者之家</p>
                </div>
                <ul class="dh-list">
                    {{navigation parentid="46"}}
                        {{foreach $list as $k => $v}}
                            <li> <a href="{{$v['url']}}" {{if $get.category|in_array:$v['allchildurl']}}class="dh-acitve"{{/if}}>{{$v['name']}}</a></li>
                        {{/foreach}}
                    {{/navigation}}
                </ul>
            </div>
            <div class="main-right">
                <div class="right-txt-box">
                    <h1>留言板</h1>
                    <div class="wz">
                        <span class="wz-span">您的位置：<a href="/">首页</a> > <a href="/liuyanban">投资者之家</a> > 留言板 </span>
                    </div>
                </div>
                <!-- 右侧的内容 -->
                <div class="box-txt">
                    <ul class="top-tabs clearfix">
                        <li class="active">你讲故事我点赞</li>
                        <li>
                            <a href="http://www.sac.net.cn/hyfw/zqjftj/zxsq/" target="_blank">
                                <img src="{{$static_path}}/static/images/investors/icon.png" alt="icon">
                                证券纠纷调解在线申请
                            </a>
                        </li>
                    </ul>
                    <div class="post-container">
                        <!-- 作者信息 -->
                        <div class="user-info clearfix">
                            {{if $member_info['headimgurl'] == ''}}
                                {{if $member_info['sex'] == 1}}
                                    <img src="{{$static_path}}/static/images/login/head_portrait2.png">
                                {{else if $member_info['sex'] == 2}}
                                    <img src="{{$static_path}}/static/images/login/head_portrait1.png">
                                {{/if}}
                            {{else}}
                                <img src="{{$member_info['headimgurl']}}">
                            {{/if}}
                            <div class="info-font">
                                <h3>
                                    {{if $member_info['nickname'] != ''}}
                                        {{$member_info['nickname']}}
                                    {{else}}
                                        {{$member_info['loginname']}}
                                    {{/if}}
                                </h3>
                                <p>请确认您拥有该作品的版权；带有 * 的项目是必填的哦。</p>
                            </div>
                        </div>
                        <form id="story">
                            <input type="hidden" name="id" value="2">
                            <ul class="post-list">
                                <li>
                                    <p class="list-title">故事标题</p>
                                    <div class="content">
                                        <input type="text" name="title" id="post-title" class="post-title" maxlength="50"
                                            onchange="this.value=this.value.substring(0,50)"
                                            onkeydown="this.value=this.value.substring(0,50)"
                                            onkeyup="this.value=this.value.substring(0,50)">
                                        <p class="remind">还可以输入 <em class="post-title-count">50</em> 字符/汉字 </p>
                                    </div>
                                </li>
                                <li>
                                    <p class="list-title">作者说明</p>
                                    <div class="content">
                                        <textarea name="post-content" id="post-content" maxlength="2000"
                                            class="post-content" onchange="this.value=this.value.substring(0,2000)"
                                            onkeydown="this.value=this.value.substring(0,2000)"
                                            onkeyup="this.value=this.value.substring(0,2000)"></textarea>
                                        <p class="remind">还可以输入 <em class="post-content-count">2000</em> 字符/汉字 </p>
                                    </div>
                                </li>
                                <li>
                                    <p class="list-title">上传图片</p>
                                    <div class="content">
                                        <div class="upload_btn clearfix">
                                            <input type="hidden" name="pic" id="dynamic-id" style="border: red 1px solid">
                                            <input class="fileinput" type="file" id="choose"
                                                accept="image/gif,image/jpeg,image/jpg,image/png" style="width:0;height:0"
                                                multiple="">
                                            <ul class="img-list"></ul>
                                            <div class="filebox" id="upload"></div>

                                            <div class="pic-list"></div>
                                        </div>
                                        <p class="remind">支持jpg/gif/png格式，< 1M，最多上传5张图片</p> 
                                    </div> 
                                </li>
                             </ul> 
                             <button class="submit" type="button" id="add-story">提交</button>
                             <!-- 弹窗样式 -->
                            <div class="tc_box" style="display: none;"></div>


                         </form>
                        </div>
                    </div>
                </div>

            </div>


        </div>

        <!--放一个id为footer的div,把footer.html加载到这块-->
        {{include file="footer.tpl"}}
        <!-- 底部部分 -->
</body>

<!-- 加载头尾 -->

<script src="{{$static_path}}/static/common/js/load.js"></script>
<script src="{{$static_path}}/static/common/js/ellipsis.js"></script>
<script src="{{$static_path}}/static/common/js/upload2.js"></script>
<script src="{{$static_path}}/static/common/js/swiper_2.7.js"></script>
<script>
    $('.zs-tabs>p').click(function () {
        $(this).addClass('zs-acitve').siblings().removeClass('zs-acitve')
    })

    // 限制字数
    $('#post-content').change(function () {
        var length = 2000 - $(this).val().length;
        $('.post-content-count').text(length);
    })
    $('#post-content').keyup(function () {
        var length = 2000 - $(this).val().length;
        $('.post-content-count').text(length);
    })
    $('#post-content').keydown(function () {
        var length = 2000 - $(this).val().length;
        $('.post-content-count').text(length);
    })

    // 限制字数
    $('#post-title').change(function () {
        var length = 50 - $(this).val().length;
        $('.post-title-count').text(length);
    })
    $('#post-title').keyup(function () {
        var length = 50 - $(this).val().length;
        $('.post-title-count').text(length);
    })
    $('#post-title').keydown(function () {
        var length = 50 - $(this).val().length;
        $('.post-title-count').text(length);
    })

    window.common_start_time = new Date();
    var __SiteAppCommon__ = {
        id: 2,
        catId: 0,
        timestamp: "1578057550.1232",
        token: "c291d0d7a547308f3e6229b9d6c93b6537d01971"
    };

    __Upload.op.uploadUrl = "/dynamic/upload-pic";
    $("#upload").on("click", function () {
        document.getElementById("choose").click();
    }).on("touchstart", function () {
        $(this).addClass("touch")
    }).on("touchend", function () {
        $(this).removeClass("touch")
    });


    document.getElementById("choose").onchange = function () {
        console.log("choose--------------start");
        __Upload.filechoose(this);
    };


    /*提交故事*/
    $("#add-story").click(function(){
        var i = 0;
        var pic = '';
        $(".img-list li").find(".progress span").each(function(){
            // console.log($(this).data('url'));
            if(i == 0){
                pic = $(this).data('url');
            }else{
                pic += ',' + $(this).data('url');
            }
            i++;
        })
        $('#dynamic-id').val(pic);
        // return;
        var data = $('form#story').serialize()
        // console.log(data)
        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: "/dynamic/add",
            data: data,
            success: function(data){
                // console.log(data)
                if(data.code == 0){
                    console.log('ok');
                    $('form#story')[0].reset()
                    $(".img-list li").remove();
                }else{
                    console.log(data.info);
                }
                $('.tc_box').html(data.info);

                $('.tc_box').show();
                setTimeout(function(){
                    $('.tc_box').html('');
                    $('.tc_box').hide(100)
                }, 1500);
            },
            error: function(){
          
            }
        })
    })
</script>

</html>